package com.moecollege.umiao.frame;

import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;
import android.view.WindowManager;

import com.facebook.common.soloader.SoLoaderShim;
import com.moecollege.moecollegelib.base.BaseActivity;
import com.moecollege.moecollegelib.utils.AndroidUtils;
import com.moecollege.umiao.R;
import com.readystatesoftware.systembartint.SystemBarTintManager;

/**
 * Created by natsuki on 15/6/4.
 */
public class UmiaoActivity extends BaseActivity {
    private Handler mHandler;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mHandler = new Handler(){
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
            }
        };
        applyKitKatTranslucency();
    }

    public Handler getHandler(){
        return mHandler;
    }
    /**
     * Apply KitKat specific translucency.
     */
    private void applyKitKatTranslucency() {

        // KitKat translucent navigation/status bar.
        if (AndroidUtils.getSDKVersion() >= Build.VERSION_CODES.KITKAT) {
            setTranslucentStatus(true);
            SystemBarTintManager mTintManager = new SystemBarTintManager(this);
            mTintManager.setStatusBarTintEnabled(true);
            mTintManager.setNavigationBarTintEnabled(true);
         //   mTintManager.setNavigationBarAlpha(1f);
            mTintManager.setTintColor(getResources().getColor(R.color.base));
//            mTintManager.setTintDrawable(UIElementsHelper
//                    .getGeneralActionBarBackground(this));

        }

    }


    private void setTranslucentStatus(boolean on) {
        Window win = getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if (on) {
            winParams.flags |= bits;
        } else {
            winParams.flags &= ~bits;
        }
        win.setAttributes(winParams);
    }
}
